package ua.org.enginer.utils.time {
	
	public function getDaysInMonth(yOrDate:Object=null, m:int=-1/*date:Date=null*/):int {
		var y:int
		if (!yOrDate) yOrDate = new Date()
		if (yOrDate is Date) {
			y = yOrDate.getFullYear()
			m = yOrDate.getMonth()+1
		}else
			y = int(yOrDate)
		
		// ($m!=2?(($m%2)^($m>7))+30:(!($y%400)||!($y%4)&&($y%25)?29:28));
		
		if (m != 2) 
			if (m/2 == Math.round(m/2)) 
				return m<8 ? 30 : 31
			else
				return m<8 ? 31 : 30
		else
			return 	y/400 == Math.round(y/400) 
					|| y/4 == Math.round(y/4) 
					&& y/25 != Math.round(y/25) ? 29 : 28
	}
}

